<style>
    .new-form-control{
        display: block;
        width: 48%;
        height: 34px;
        font-size: 14px;
        border: 1px solid #ccc;
        float: left;
        margin-bottom: 10px;
    }
    .new-input{
        border: 0;
        float: left;
        width: 4%;
        height: 34px;
        text-align: center;
    }
    .new-date{
        display: block;
        width: 44%;
        height: 34px;
        font-size: 14px;
        border: 1px solid #ccc;
        float: left;
    }
    .new-date-i{
        float: left;
        width: 8%;
        height: 34px;
    }
    .new-units{
        height: 34px;
        width: 20%;
        font-size: 16px;
        float: left;
        margin-bottom: 10px;
    }
    .new-sum{
        display: block;
        width: 80%;
        height: 34px;
        font-size: 14px;
        border: 1px solid #ccc;
        float: left;
        margin-bottom: 10px;
    }
</style>
<!--添加弹出框-->
<div class="wizard" id="wizard-demo">
    <form method="post" onsubmit="add()" id="addForm">
        <h1>添加订单执行</h1>
        <div class="wizard-card" data-onValidated="setServerName" data-cardname="name">
            <h3><span>订单执行信息</span></h3>

            <div class="wizard-input-section">

                <div class="form-group">
                    <label>订单评审号</label>
                    <select class="form-control" name="oid_add" id="oid_add" onchange="getOid(this.options[this.options.selectedIndex].value)">
                        <option value=""></option>
                        {volist name="orders" id="v"}
                        <option value="{$v.oid}">{$v.oid}</option>
                        {/volist}
                    </select>
                </div>
                <div id="fromoid" class="forhid">
                    <div class="form-group">
                        <label>国家</label>
                        <input type="text" class="form-control" readonly name="sid_add" id="sid_add" data-validate=""/>
                    </div>
                    <div class="form-group">
                        <label>客户</label>
                        <input type="text" class="form-control" readonly name="cid_add" id="cid_add" data-validate=""/>
                    </div>
                    <div class="form-group">
                        <label>基表型号</label>
                        <input type="text" class="form-control" readonly name="meter_id_add" id="meter_id_add" data-validate=""/>
                    </div>
                    <div class="form-group">
                        <label>表数量</label>
                        <input type="text" class="form-control" readonly name="order_qty_add" id="order_qty_add" data-validate=""/>
                    </div>
                    <div class="form-group">
                        <label>生产状态</label>
                        <input type="text" class="form-control" readonly name="is_status_oid" id="is_status_oid" data-validate=""/>
                    </div>
                </div>

            </div>

        </div>

        <div class="wizard-card" data-cardname="group">
            <h3><span>模块信息</span></h3>

            <div class="wizard-input-section">
                <div class="form-group">
                    <label>电子模块类型</label>
                    <select class="form-control" name="model_id_add" id="model_id_add" data-validate="">
                        {volist name="modelTypes" id="v"}
                        <option value="{$v['model_id']}">{$v.model_type}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group">
                    <label>模块订单号</label>
                    <input type="text" class="form-control" name="model_num_add" id="model_num_add" data-validate="" onchange="getModelNum()"/>
                </div>
                <div class="form-group">
                    <label>模块数量</label>
                    <input type="text" class="form-control" name="model_qty_add" id="model_qty_add" data-validate=""/>
                </div>
                <input type="text" class="form-control forhid" style="border: 0;color: red;margin-top: -14px;" id="firstadd" data-validate=""/>
                <div class="form-group">
                    <label for="model_start_add">模块下单开始-结束时间</label>
                    <div class="form-group">
                        <span class="input-group-addon new-date-i"><i class="fa fa-calendar"></i></span>
                        <input type="date" id="model_start_add" name="model_start_add" class="new-date">
                        <input type="text" placeholder="--" class="new-input">
                        <input type="date" id="model_end_add" name="model_end_add" class="new-date">
                    </div>

                </div>
            </div>
        </div>

        <div class="wizard-card" data-onload="" data-cardname="location">
            <h3><span>基表信息</span></h3>

            <div class="wizard-input-section">
                <div class="form-group">
                    <label>基表订单号</label>
                    <input type="text" name="order_num_add" class="form-control">
                </div>
                <div class="form-group" id="meter_num_add">
                    <label>开始表号-结束表号</label>
                    <div class="form-group">
                        <input type="text" name="meter_start_add" class="new-form-control">
                        <input type="text" placeholder="--" class="new-input">
                        <input type="text" name="meter_end_add" class="new-form-control">
                    </div>
                </div>
                <div class="form-group forhid" id="meter_num_fix">
                    <input type="text" name="meter_len_add" readonly style="border: 0;color: red;width: 100%;">
                </div>
                <div class="form-group">
                    <label>基表组装开始-完成时间</label>
                    <div class="form-group">
                        <span class="input-group-addon new-date-i"><i class="fa fa-calendar"></i></span>
                        <input type="date" id="assem_start_add" name="assem_start_add" class="new-date">
                        <input type="text" placeholder="--" class="new-input">
                        <input type="date" id="assem_end_add" name="assem_end_add" class="new-date">
                    </div>
                </div>

            </div>
        </div>

        <div class="wizard-card">
            <h3><span>生产信息</span></h3>

            <div class="wizard-input-section">
                <div class="form-group">
                    <label>制造商</label>
                    <select class="form-control" name="mf_id_add" id="mf_id_add" data-validate="">
                        {volist name='manus' id='v'}
                        <option value="{$v['mf_id']}">{$v.manufacturer}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group">
                    <label>生产负责人</label>
                    <select class="form-control" name="pid_add" id="pid_add" data-validate="">
                        {volist name='principles' id='v'}
                        <option value="{$v['pid']}">{$v.product_principle}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group">
                    <label>客户化工具</label>
                    <select class="form-control" name="custom_tool_add" id="custom_tool_add">
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                </div>

                <div class="form-group">
                    <label>生产数据校验</label>
                    <select class="form-control" name="data_verify_add" id="data_verify_add" data-validate="">
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                </div>
                <div class="form-group">
                    <label>发货状态</label>
                    <select class="form-control" name="is_status_add" id="is_status_add" data-validate="">
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                </div>

            </div>
        </div>


        <div class="wizard-card">
            <h3><span>其他相关信息</span></h3>

            <div class="wizard-input-section">
                <div class="form-group">
                    <label>所属业务部门</label>
                    <select class="form-control" name="sale_id_add" id="sale_id_add">
                        <option value="1">业务一部</option>
                        <option value="2">业务二部</option>
                        <option value="3">业务三部</option>
                        <option value="4">业务四部</option>
                    </select>
                </div>
                <div class="form-group">
                    <label>订单金额-单位</label>
                    <div>
                        <input type="text" name="sum_amounts_add" id="sum_amounts_add" class="new-sum">
                        <select name="sum_units_add" id="sum_units_add" class="new-units">
                            <option value="$">$</option>
                            <option value="￥">￥</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label>备注</label>
                    <input type="text" name="comments_add" class="form-control" data-validate="">
                </div>

            </div>
        </div>

    </form>
</div>
<!--添加弹出框-->
<script src="__JS__/jquery.js"></script>
<script type="text/javascript">
    //根据订单评审id展示相关信息
    function getOid(oid) {
        $('#fromoid').removeClass('forhid')
        $.post("{:url('Order/one')}",{oid:oid},function(data){
            //console.log(data);
            if(data) {
                $("input[name='meter_id_add']").val(data[0].meter_type)
                $("input[name='cid_add']").val(data[0].client);
                $("input[name='sid_add']").val(data[0].state);
                $("input[name='is_status_oid']").val(data[0].status);
                $("input[name='order_qty_add']").val(data[0].order_qty);
                var meterLen = data[0].meter_len;
                //如果没有表号长度
                if(meterLen != 0){
                    $('#meter_num_fix').removeClass('forhid')
                    $("input[name='meter_len_add']").val('请输入 '+meterLen+' 位表号')
                }else{
                    $('#meter_num_fix').removeClass('forhid')
                    $("input[name='meter_len_add']").val('请输入 10,11,12或13 位表号')
                }
            }
        },'json');
    }
    function getModelNum() {
        var modelNum = $('#model_num_add').val();
        //console.log(modelNum)
        $.ajax({
            //几个参数需要注意一下
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "{:url('Execorder/getModelNum')}",//url
            data: {'model_num':modelNum},
            success: function (result) {
                var num = result.model_qty;
                var start = result.model_start;
                var end = result.model_end;
                var first = result.firstadd;
                //console.log(num+','+start+','+end)
                $('#model_qty_add').val(num)
                $('#model_start_add').val(start)
                $('#model_end_add').val(end)
                //console.log('success'+result)
                if(first != ''){
                    $('#firstadd').removeClass('forhid')
                    $('#firstadd').val(first)
                }

            },
            error:function (result) {
                //console.log('error'+result)
                alert('服务出错')
            }
        });
    }


</script>
